const mysql = require('mysql');

let pool = mysql.createPool({
    host:'localhost',
    user:'root',
    password:'root',
    database:'badminton_db',
    timezone:'08:00'
})

function query(sql,arr,callback){
    pool.getConnection( function (err,connection){
        if(err) throw err
        console.log('连接至数据库');
        connection.query(sql,arr,function(err,results){
           console.log(sql);
           callback(results,err)
               
          // 释放链接
           connection.release();
           
        })
    })
}

exports.query = query;